<?php
/**
 * 分数修改、添加表单、删除操作
 */
include "../util/DBUtil.php";
include "../util/PromptAction.php";
$db = new DBUtil();

$action = $_GET['flag'];
$stuId = $_GET['id'];
if ($action==1){//删除
    $sql = "delete from tb_score where student_id=? ";
    $params = array($stuId);
    $statue = $db->delete($sql,$params);
    showStatue($statue);
    echo "<script>window.open('score.php','info')</script>";
    return;
}elseif ($action==0){
    $sql = "select * from tb_course";
    $course_result = $db->query($sql);//获取所有课程
    $sql = "select * from v_student where id=? ";
    $params = array($stuId);
    $stu_result = $db->query($sql,$params)[0];
}

?>

<form action="../action/score_formOK.php?action=edit" method="post">
    <input type="hidden" value="<?php echo $stuId?>" name="stuId">
    <table>
        <tr>
            <td>学号：</td><td><input type="text"  value="<?php echo $stu_result['student_no']?>" disabled></td>
        </tr>
        <tr>
            <td>姓名：</td><td><input type="text" value="<?php echo $stu_result['name']?>" disabled></td>
        </tr>
        <?php
        foreach ($course_result as $item){
            ?>
            <tr>
                <td><?php echo $item['course']?></td><td><input type="text" name="score<?php echo $item['id']?>" ></td>
            </tr>
            <?php
        }
        ?>
    </table>
    <button type="submit" formtarget="info">确定</button>
</form>
